package com.eaoa.uc.permission.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.eaoa.base.EABaseAction;
import com.eaoa.uc.permission.bo.RoleRemoveAccountBO;
import com.stony.core.util.CoreUtils;

public class DelRoleEmployeeAction extends EABaseAction {
	protected ActionForward doWork(ActionMapping mapping, ActionForm form,
	HttpServletRequest request, HttpServletResponse response)
	throws Exception {

		Long roleno = CoreUtils.parseLong(request.getParameter("roleno"));
		String[] employeenos = request.getParameterValues("employeenos");

		for (int i = 0; i < employeenos.length; i++) {
			Long employeeno = CoreUtils.parseLong(employeenos[i]);

			if (employeeno != null && employeeno.intValue()!=-1) {
				List rolenos = new ArrayList();
				rolenos.add(roleno);
				RoleRemoveAccountBO bo = new RoleRemoveAccountBO(employeeno, rolenos);
				bo.execute();
			}
		}

		request.setAttribute("roleno", roleno);

		return mapping.findForward("success");
	}

}